function trim(val)
{
	 return val.replace(/(^\s*)|(\s*$)/g, "");
}

function isMaxLen(o)
{
	 var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";
	 if(o.getAttribute && o.value.length>nMaxLen)
	 {
	 	  o.value=o.value.substring(0,nMaxLen);
	 }
}



function selectAll(){
	var checkall = document.getElementById('checkall');
	var listsize = document.getElementById('listsize').value;
	for(var i=0;i<listsize;i++){
		if(checkall.checked){
			document.getElementById('checkone'+i).checked = true;
		}else{
			document.getElementById('checkone'+i).checked = false;
		}
	}
}

function judgeCheck()
{
    var pkid_string = '';
		var listsize = document.getElementById('listsize').value;
		for(var i=0;i<listsize;i++)
		{
				if(document.getElementById('checkone'+i).checked)
				{
					pkid_string += document.getElementById('checkone'+i).value+'|';
				}
		}
    return pkid_string;
}

//var one_member_price ='';




function operateInfo(val){

	var oper = document.getElementById(val+'_operating').value;
	if(oper == ''){
		alert('请选择操作方式!');
		return false;
	}

	var listsize = document.getElementById('listsize').value;

	var pkid_string = judgeCheck();
	if( pkid_string == '' ){
		alert('请至少选择一条信息进行操作!');
		return false;
	}
	if( oper == '-' ){
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action = '/doTradeReg.do';
		document.getElementById('bpm_id').value = '4335';
		if(window.confirm('确认删除吗?')){
			document.indexForm.submit();
		}
 	} else if( 'abcd'.indexOf(oper) > -1 ) {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '8432';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	} else {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '2491';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	}

}

function changeTime(){

	var obj = document.getElementById('up_operating').value;
	if( obj == '' || obj.indexOf('-')>-1 || obj.indexOf('c')>-1 || obj.indexOf('d')>-1 ){
		document.getElementById('b_g').style.display = 'none';
	}else{
		document.getElementById('b_g').style.display = 'inline';
	}
}


function changetype() {

	var pkid_string = judgeCheck();
	if( pkid_string == '' ){
		alert('请至少选择一条信息进行操作!');
		return false;
	}
	document.getElementById('pkid').value = pkid_string;
	document.indexForm.action = '/doTradeReg.do';
	document.getElementById('bpm_id').value = '5135';
	if(window.confirm('确认修改简历类型吗?')){
		document.indexForm.submit();
	}
}

function deleteOneInfo(pkid,bpm_id)
{

	if(window.confirm('确认删除吗？'))
	{
	  window.location.href='/doTradeReg.do?pkid='+pkid+'&bpm_id='+bpm_id;
 	}
}


function textCounter(field, maxlimit)   {

	if(field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);

}

function subForm(){

	if(trim(document.getElementById('resume_title').value)==''){
	  alert('请输入简历标题！');
	  document.getElementById('resume_title').focus();
	  return false;
	}
	if(trim(document.getElementById('resume_name').value)==''){
	  alert('请输入姓名！');
	  document.getElementById('resume_name').focus();
	  return false;
	}

	if(trim(document.getElementById('birth').value)==''){
	  alert('请输入出生日期！');
	  document.getElementById('birth').focus();
	  return false;
	}

	if(document.getElementById('d_province').value != ''){
		var area_attr = '';
		area_attr += document.getElementById('d_province').value+'|';
		if(document.getElementById('d_eparchy_code').value!=''){
			area_attr += document.getElementById('d_eparchy_code').value+'|';
			if(document.getElementById('d_city_code').value!=''){
				area_attr += document.getElementById('d_city_code').value+'|';
			}
		}
		if(area_attr == ''){
			alert('请选择国家或地区！');
			return false;
		}
		document.getElementById('area_attr').value = area_attr;
	}

	if(trim(document.getElementById('cert_number').value)==''){
	  alert('请输入证件号码！');
	  document.getElementById('cert_number').focus();
	  return false;
	}
	if(trim(document.getElementById('email').value)==''){
	  alert('请输入电子邮箱！');
	  document.getElementById('email').focus();
	  return false;
	}
	var email=document.getElementById('email').value;
	myReg = "^((https|http|ftp|rtsp|mms)?://)"+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
			+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
			+ "|" // 允许IP和DOMAIN（域名）
			+ "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
			+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
			+ "[a-z]{2,6})" // first level domain- .com or .museum
			+ "(:[0-9]{1,4})?" // 端口- :80
			+ "((/?)|" // a slash isn't required if there is no file name
			+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";

	if (email=!""&&!email.match(myReg)){
		alert("请输入正确的邮箱地址！");
		document.getElementById('email').focus();
		return false;
 	}
	if(trim(document.getElementById('frist_contact').value)==''){
	  alert('请输入联系方式！');
	  document.getElementById('frist_contact').focus();
	  return false;
	}

	if(document.getElementById('h_province').value != ''){
		var account_location = '';
		account_location += document.getElementById('h_province').value+'|';
		if(document.getElementById('h_eparchy_code').value!=''){
			account_location += document.getElementById('h_eparchy_code').value+'|';
			if(document.getElementById('h_city_code').value!=''){
				account_location += document.getElementById('h_city_code').value+'|';
			}
		}
		if(account_location == ''){
			alert('请选择户口所在地！');
			return false;
		}
		document.getElementById('account_location').value = account_location;
	}

	if(trim(document.getElementById('address').value)==''){
	  alert('请输入现居住地址！');
	  document.getElementById('address').focus();
	  return false;
	}

	if(trim(document.getElementById('start_date').value)==''){
	  alert('请选择入学时间！');
	  document.getElementById('start_date').focus();
	  return false;
	}

	if(trim(document.getElementById('end_date').value)==''){
	  alert('请选择毕业时间！');
	  document.getElementById('end_date').focus();
	  return false;
	}
	if(trim(document.getElementById('college_name').value)==''){
	  alert('请输入学校名称！');
	  document.getElementById('college_name').focus();
	  return false;
	}
	if(trim(document.getElementById('specialty').value)==''){
	  alert('请输入专业名称！');
	  document.getElementById('specialty').focus();
	  return false;
	}


	var v = 0;

	var degree = document.getElementsByName('degree');
	for (var i = 0; i < degree.length; i++){
		if(degree[i].checked) {
			v++;
		}
	}
	if(v == 0){
		alert('请选择学历/学位！');
		return false;
	}

	if(trim(document.getElementById('self_title').value)==''){
	  alert('请输入自我评价标题！');
	  document.getElementById('self_title').focus();
	  return false;
	}

	if(trim(document.getElementById('self_content').value)==''){
	  alert('请输入自我评价内容！');
	  document.getElementById('self_content').focus();
	  return false;
	}


	var c = 0;

	var q_work_kind = document.getElementsByName('q_work_kind');
	for (var i = 0; i < q_work_kind.length; i++){
		if(q_work_kind[i].checked) {
			c++;
		}
	}
	if(c == 0){
		alert('请选择期望工作性质！');
		return false;
	}

	if(document.getElementById('q_province').value != ''){
		var q_work_addr = '';
		q_work_addr += document.getElementById('q_province').value+'|';
		if(document.getElementById('q_eparchy_code').value!=''){
			q_work_addr += document.getElementById('q_eparchy_code').value+'|';
		}
		document.getElementById('q_work_addr').value = q_work_addr;
	} else {
		if(document.getElementById('q_work_addr').value == ''){
		alert('请选择期望工作地区！');
		return false;
		}
	}

	if(trim(document.getElementById('q_work_career').value)==''){
	  alert('请选择期望从事职业！');
	  document.getElementById('q_work_career').focus();
	  return false;
	}

	if(trim(document.getElementById('q_work_biz').value)==''){
	  alert('请选择期望从事行业！');
	  document.getElementById('q_work_biz').focus();
	  return false;
	}
	
	if(document.getElementById('work_date').value == '1'){
		document.getElementById('is_work').value = '1';
	}
	
	var n = 0;

	var smObj = document.getElementsByName('posts');
	for (var i = 0; i < smObj.length; i++){
		if(smObj[i].checked) {
			n++;
		}
	}

	if(n == 0){
		alert('请选择上岗情况！');
		return false;
	}

	document.addForm.submit();

}

function change( val ){
	if( val == '1' ){
		document.getElementById('reson1').style.display = 'block';
		document.getElementById('reson2').style.display = 'block';
	}
	else{
		document.getElementById('reson1').style.display = 'none';
		document.getElementById('reson2').style.display = 'none';
	}
}

function ChangeClassStyle(){
	document.getElementById("class_attr").value = '';
	document.getElementById("classId1").style.display = 'none';
	document.getElementById("classId2").style.display = 'block';
}

function ChangeAreaStyle(){
	document.getElementById("area_attr").value = '';
	document.getElementById("areaId1").style.display = 'none';
	document.getElementById("areaId2").style.display = 'block';
}

function searchForm(){

	document.indexForm.submit();

}


function setProvince()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('h_province');
		DWRUtil.addOptions('h_province',{'':'请选择'});
		DWRUtil.addOptions('h_province',data);
	})
}
function setCitys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('h_eparchy_code');
		DWRUtil.addOptions('h_eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('h_eparchy_code',data);
		DWRUtil.removeAllOptions('h_city_code');
		DWRUtil.addOptions('h_city_code',{'':'请选择'});
	});
}

function setAreas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('h_city_code');
		DWRUtil.addOptions('h_city_code',{'':'请选择'});
	 	DWRUtil.addOptions('h_city_code',data);
	});
}


function _set_Province()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('d_province');
		DWRUtil.addOptions('d_province',{'':'请选择'});
		DWRUtil.addOptions('d_province',data);
	})
}
function _set_Citys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('d_eparchy_code');
		DWRUtil.addOptions('d_eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('d_eparchy_code',data);
		DWRUtil.removeAllOptions('d_city_code');
		DWRUtil.addOptions('d_city_code',{'':'请选择'});
	});
}

function _set_Areas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('d_city_code');
		DWRUtil.addOptions('d_city_code',{'':'请选择'});
	 	DWRUtil.addOptions('d_city_code',data);
	});
}



function set_Province()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('q_province');
		DWRUtil.addOptions('q_province',{'':'请选择'});
		DWRUtil.addOptions('q_province',data);
	})
}
function set_Citys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('q_eparchy_code');
		DWRUtil.addOptions('q_eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('q_eparchy_code',data);
		DWRUtil.removeAllOptions('q_city_code');
		DWRUtil.addOptions('q_city_code',{'':'请选择'});
	});
}


function addLang( val ){

	var is_work = document.getElementById("is_work").value;
	if( val == '2' && is_work !='1'){
		document.getElementById("jumpurl").value = "/program/admin/resume/addexperience.jsp";
	}
	if( val == '2' && is_work =='1'){
		document.getElementById("jumpurl").value = "/program/admin/resume/index.jsp";
	}	

	var resume_id = document.getElementById("resume_id").value;
	var lang_type = document.getElementById("lang_type").value;
	$.ajax({
		type: "POST",
		cache:false,
        async:false,
		url: "/program/admin/resume/checkRepeat.jsp",
		data: "resume_id="+resume_id+"&lang_type="+lang_type,
		success: function(data){
			 if(data!=null && data!=""){
				if( data == 1 ){
					alert('请勿重复选择此语种');
					return false;
				}else{
					document.addForm.submit();
				}
			 }
		}

	});

}

function addexp( val ){


	if(trim(document.getElementById('company').value)==''){
	  alert('请输入企业名称！');
	  document.getElementById('company').focus();
	  return false;
	}
	if(trim(document.getElementById('depart').value)==''){
	  alert('请输入所在部门！');
	  document.getElementById('depart').focus();
	  return false;
	}
	if(trim(document.getElementById('career_type').value)==''){
	  alert('请输入职位类别！');
	  document.getElementById('career_type').focus();
	  return false;
	}
	if(trim(document.getElementById('career').value)==''){
	  alert('请输入职位名称！');
	  document.getElementById('career').focus();
	  return false;
	}
	if(trim(document.getElementById('work_date').value)==''){
	  alert('请输入工作时间！');
	  document.getElementById('work_date').focus();
	  return false;
	}
	if(trim(document.getElementById('work_desc').value)==''){
	  alert('请输入工作描述！');
	  document.getElementById('work_desc').focus();
	  return false;
	}



	if( val == '1'){
		document.getElementById("jumpurl").value = "/program/admin/resume/addexperience.jsp";
	}
	if( val == '2'){
		document.getElementById("jumpurl").value = "/program/admin/resume/index.jsp";
	}
	document.addForm.submit();
}

function listSearch(){
	var province = document.getElementById("q_province").value;
	var city = document.getElementById("q_eparchy_code").value;
	var addr = "";
	if(province!=""){
		addr += province+"|";
		if(city!=""){
			addr += city;
		}
	}
	document.getElementById("q_work_addr_para").value = addr;
	document.indexForm.submit();
}